/**
 *  @auth xlx_good@qq.com
 *  @date 17/6/21.
 *
 */

requirejs.config({
    baseUrl: 'js/',
    paths:  {
        avalon: 'plugins/avalon/avalon.min',
        jquery: 'plugins/jquery/jquery-1.11.3.min',
        api: 'api',
    },
    shim: {
        api: {
            deps: ['jquery']
        }
    }
});


(function(win, dom, requirejs, initVm){
    var vm;
    requirejs(['avalon', 'jquery', 'api', 'config'], function(){
        //初始化vm
        vm = initVm(dom);
		vm.verifyCode();
    });

})(window, document, requirejs, function(dom){
    var vm = avalon.define({
        $id: 'container',
		code: '',
		msg: '',
        form: {
			userName: '',
			userPwd: '',
			verifyCode: ''
		},
        verifyCode: function(e) {
			vm.code = Api.verifyCode();
		},
		login: function(e) {
			location.href = 'main.html';
//			Api.login(vm.form, function(resp) {
//				if(resp.code == 0) {
//					location.href = 'main.html';
//				} else {
//					vm.msg = resp.msg;
//				}
//			});
		}
    })
    avalon.scan(dom.body);
    return vm;
});

